

//
//  UIView+Extension.swift
//  HotNews
//
//  Created by YYY on 2017/10/17.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

import Foundation

extension UIView
{
    // MARK: x
    var x: CGFloat
    {
        return frame.origin.x
    }
    func setX(newX: CGFloat)
    {
        var newFrame = frame
        newFrame.origin.x = newX
        frame = newFrame
    }
    
    // MARK: y
    var y: CGFloat
    {
        return frame.origin.y
    }
    func setY(newY: CGFloat)
    {
        var newFrame = frame
        newFrame.origin.y = newY
        frame = newFrame
    }
    
    // MARK: width
    var width: CGFloat
    {
        return frame.size.width
    }
    func setWidth(newWidth: CGFloat)
    {
        var newFrame = frame
        newFrame.size.width = newWidth
        frame = newFrame
    }
    
    // MARK: height
    var height: CGFloat
    {
        return frame.size.height
    }
    func setHeight(newHeight: CGFloat)
    {
        var newFrame = frame
        newFrame.size.height = newHeight
        frame = newFrame
    }
    
    // MARK: top
    var top: CGFloat
    {
        return frame.origin.y
    }
    func setTop(newTop: CGFloat)
    {
        var newFrame = frame
        newFrame.origin.y = newTop
        frame = newFrame
    }
    
    // MARK: left
    var left: CGFloat
    {
        return frame.origin.x
    }
    func setLeft(newLeft: CGFloat)
    {
        var newFrame = frame
        newFrame.origin.x = newLeft
        frame = newFrame
    }
    
    // MARK: bottom
    var bottom: CGFloat
    {
        return frame.origin.y + frame.size.height
    }
    func setBottom(newBottom: CGFloat)
    {
        var newFrame = frame
        newFrame.origin.y = newBottom - newFrame.size.height
        frame = newFrame
    }
    
    // MARK: right
    var right: CGFloat
    {
        return frame.origin.x + frame.size.width
    }
    func setRight(newRight: CGFloat)
    {
        let edge = newRight - right
        var newFrame = frame
        newFrame.origin.x += edge
        frame = newFrame
    }
    
    // MARK: size大小
    var size: CGSize
    {
        return frame.size
    }
    
    // MARK: orgin坐标
    var orgin: CGPoint
    {
        return frame.origin
    }

}
